/**
 * 设置 Storage
 * @param {string} key 
 * @param {any} val 
 */
export function setLocal(key, val) {
    if (val === 'undefined' || val === 'null') { val = null }
    var data = {
        data: val,
        time: Date.now(),
        type: typeof val
    }
    // data = JSON.stringify(data)
    wx.setStorageSync(key, data)
}

/**
 * 获取 Storage
 * @param {string} key 
 * @returns {any}
 */
export function getLocal(key) {
    var result = wx.getStorageSync(key)
    if (!result) { return null }
    // result = JSON.parse(result)
    return result.data
}

/**
 * 清除 Storage
 * @param {string} key 
 */
export function delLocal(key) {
    return wx.removeStorageSync(key)
}